home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / lang / lisp / glisp / glisp.000 / GLISP.UNIX.TAR / closunix / closyacc.cux < prev    next >
Encoding:
Text File  |  1995-04-03  |  22.0 KB  |  829 lines

  1.  
  2. # line 2 "closyacc.y"
  3. /*                                CLOS                          */
  4. /*        Scritto nel 1990-91-92 da Zoia Andrea Michele     */
  5. /*        Via Pergola #1 Tirano (SO) Tel. 0342-704210    */
  6. #include"clos.h"
  7. #include"closerr.h"
  8.  
  9. #define YYMAXDEPTH     1000    /* Yacc stack depth */
  10. #define PROMPT          { sprintf(buf1,"%s",yacc_prompt);\
  11.                           lisp_print_string(buf1,yacc_fileout);}
  12. #define PROMPTP         { sprintf(buf1,"%u%s",parcount,yacc_prompt);\
  13.                           lisp_print_string(buf1,yacc_fileout);}
  14.  
  15. extern     int     parcount;
  16. int         yywrapcalled;
  17. node         yyret;
  18. char        *yacc_prompt;
  19. FILE        *yacc_filein;
  20. FILE        *yacc_fileout;
  21.  
  22. int yywrap();
  23. int yyerror();
  24.  
  25. node input_func(fin,fout,pr)
  26. FILE *fin;
  27. FILE *fout;
  28. char *pr;
  29. {
  30.  yacc_filein=fin;yacc_fileout=fout;
  31.  parcount=0;yacc_prompt=pr;
  32.  yywrapcalled=FALSE;
  33.  if(yyparse()){ /* error... */
  34.         if(yywrapcalled)
  35.                 error(E_EOF,ERR_MERROR|ERR_PVOID|ERR_TNORM,NULL);
  36.     else{
  37.                 error(E_YACCSTACK,ERR_MERROR|ERR_PVOID|ERR_TNORM,NULL);
  38.                 /* svuota il buffer d'ingresso */
  39.                 while(lisp_get_char(yacc_filein)!='\n');
  40.         }
  41.         PROMPT;
  42.         /* ritorna al main-loop */
  43.         error(E_ZERO,ERR_MNONE|ERR_PVOID|ERR_TBLVL,NULL);
  44.  }
  45.  if(yyret==VOID){
  46.    PROMPT;
  47.    /* ritorna al main-loop */
  48.    /* error(E_ZERO,ERR_MNONE|ERR_PVOID|ERR_TBLVL,NULL); */
  49.  }
  50.  return yyret;
  51. }
  52.  
  53. int yywrap()
  54. { return yywrapcalled=TRUE; }
  55.  
  56. int yyerror(s)
  57. char *s;
  58. { return TRUE; }
  59.  
  60.  
  61. # line 61 "closyacc.y"
  62. typedef union {
  63.     char        *ident;
  64.     double        real;
  65.     long int    integer;
  66.     node        s_expr;
  67. } YYSTYPE;
  68. # define IDENTIFIER_YY 257
  69. # define STRING_YY 258
  70. # define INTEGER_YY 259
  71. # define REAL_YY 260
  72. # define BAD_CHAR_YY 261
  73. # define BAD_STRING_YY 262
  74. # define BAD_SQB_YY 263
  75. #define yyclearin yychar = -1
  76. #define yyerrok yyerrflag = 0
  77. extern int yychar;
  78. extern int yyerrflag;
  79. #ifndef YYMAXDEPTH
  80. #define YYMAXDEPTH 150
  81. #endif
  82. YYSTYPE yylval, yyval;
  83. typedef int yytabelem;
  84. # define YYERRCODE 256
  85.  
  86. # line 182 "closyacc.y"
  87.  
  88.  
  89. yytabelem yyexca[] ={
  90. -1, 0,
  91.     257, 22,
  92.     258, 22,
  93.     259, 22,
  94.     260, 22,
  95.     261, 22,
  96.     262, 22,
  97.     263, 22,
  98.     10, 22,
  99.     40, 22,
  100.     38, 22,
  101.     58, 22,
  102.     39, 22,
  103.     44, 22,
  104.     126, 22,
  105.     35, 22,
  106.     -2, 0,
  107. -1, 1,
  108.     0, -1,
  109.     -2, 0,
  110.     };
  111. # define YYNPROD 24
  112. # define YYLAST 271
  113. yytabelem yyact[]={
  114.  
  115.      5,    26,    25,    21,     3,    32,    16,    18,     8,    23,
  116.      5,    36,    19,    35,    22,     1,     7,     5,     6,     5,
  117.      0,     0,     0,     0,     0,    21,    17,     0,    16,    18,
  118.      8,    34,     0,     0,    19,    21,    40,     0,    16,    18,
  119.      8,    34,    21,    38,    19,    16,    18,     8,    17,    33,
  120.     44,    19,     4,     0,     2,     0,     0,     0,    17,     0,
  121.      0,     0,     0,    24,     0,    17,    27,    28,    29,    30,
  122.     31,     0,     0,     0,     0,     0,     0,     0,     0,     0,
  123.      0,     0,    37,     0,     0,     0,     0,     0,    39,     0,
  124.      0,    42,     0,     0,    20,    41,     0,    43,     0,     0,
  125.      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
  126.      0,     0,     0,     0,     0,     0,    20,     0,     0,     0,
  127.      0,     0,     0,     0,     0,     0,    20,     0,     0,     0,
  128.      0,     0,     0,    20,     0,     0,     0,     0,     0,     0,
  129.      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
  130.      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
  131.      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
  132.      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
  133.      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
  134.      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
  135.      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
  136.      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
  137.      0,     0,     0,     0,     0,    12,    11,     9,    10,    13,
  138.     14,    15,     0,     0,     0,     0,     0,     0,     0,     0,
  139.      0,     0,     0,     0,     0,     0,     0,    12,    11,     9,
  140.     10,    13,    14,    15,     0,     0,     0,    12,    11,     9,
  141.     10,    13,    14,    15,    12,    11,     9,    10,    13,    14,
  142.     15 };
  143. yytabelem yypact[]={
  144.  
  145.   -252, -3000,     7,     4, -3000, -3000, -3000, -3000, -3000, -3000,
  146.  -3000, -3000, -3000,  -254, -3000,  -255,   -32,   -32,   -32,   -32,
  147.    -32,   -34, -3000, -3000,     0,     3,     1, -3000, -3000, -3000,
  148.  -3000, -3000,   -32, -3000, -3000, -3000, -3000, -3000, -3000,   -10,
  149.  -3000,     7, -3000,     9, -3000 };
  150. yytabelem yypgo[]={
  151.  
  152.      0,    18,     9,    16,    49,    15,    54 };
  153. yytabelem yyr1[]={
  154.  
  155.      0,     5,     5,     4,     4,     4,     1,     1,     1,     1,
  156.      1,     1,     1,     3,     3,     3,     3,     3,     3,     2,
  157.      2,     2,     6,     6 };
  158. yytabelem yyr2[]={
  159.  
  160.      0,     5,     5,     3,     3,     5,     3,     3,     3,     3,
  161.      7,     3,     7,     5,     5,     5,     5,     5,     7,     7,
  162.      5,    17,     0,     5 };
  163. yytabelem yychk[]={
  164.  
  165.  -3000,    -5,    -6,   256,    -4,    10,    -1,    -3,    40,   259,
  166.    260,   258,   257,   261,   262,   263,    38,    58,    39,    44,
  167.    126,    35,    10,    -2,    -6,   256,   256,    -4,    -4,    -4,
  168.     -4,    -4,    39,    -4,    41,    10,    10,    -4,    -2,    -6,
  169.     46,    -6,    -4,    -6,    41 };
  170. yytabelem yydef[]={
  171.  
  172.     -2,    -2,     0,     0,     1,    23,     3,     4,    22,     6,
  173.      7,     8,     9,     0,    11,     0,     0,     0,     0,     0,
  174.      0,     0,     2,     5,     0,     0,     0,    13,    14,    15,
  175.     16,    17,     0,    22,    20,    10,    12,    18,    19,     0,
  176.     22,     0,    22,     0,    21 };
  177. typedef struct { char *t_name; int t_val; } yytoktype;
  178. #ifndef YYDEBUG
  179. #    define YYDEBUG    0    /* don't allow debugging */
  180. #endif
  181.  
  182. #if YYDEBUG
  183.  
  184. yytoktype yytoks[] =
  185. {
  186.     "IDENTIFIER_YY",    257,
  187.     "STRING_YY",    258,
  188.     "INTEGER_YY",    259,
  189.     "REAL_YY",    260,
  190.     "BAD_CHAR_YY",    261,
  191.     "BAD_STRING_YY",    262,
  192.     "BAD_SQB_YY",    263,
  193.     "-unknown-",    -1    /* ends search */
  194. };
  195.  
  196. char * yyreds[] =
  197. {
  198.     "-no such reduction-",
  199.     "ass : n sexpr",
  200.     "ass : error '\n'",
  201.     "sexpr : atom",
  202.     "sexpr : macro",
  203.     "sexpr : '(' list",
  204.     "atom : INTEGER_YY",
  205.     "atom : REAL_YY",
  206.     "atom : STRING_YY",
  207.     "atom : IDENTIFIER_YY",
  208.     "atom : BAD_CHAR_YY error '\n'",
  209.     "atom : BAD_STRING_YY",
  210.     "atom : BAD_SQB_YY error '\n'",
  211.     "macro : '&' sexpr",
  212.     "macro : ':' sexpr",
  213.     "macro : '\'' sexpr",
  214.     "macro : ',' sexpr",
  215.     "macro : '~' sexpr",
  216.     "macro : '#' '\'' sexpr",
  217.     "list : n sexpr list",
  218.     "list : n ')'",
  219.     "list : n sexpr n '.' n sexpr n ')'",
  220.     "n : /* empty */",
  221.     "n : n '\n'",
  222. };
  223. #endif /* YYDEBUG */
  224. #define YYFLAG  (-3000)
  225. /* @(#) $Revision: 64.2 $ */    
  226.  
  227. /*
  228. ** Skeleton parser driver for yacc output
  229. */
  230.  
  231. #if defined(NLS) && !defined(NL_SETN)
  232. #include <msgbuf.h>
  233. #endif
  234.  
  235. #ifndef nl_msg
  236. #define nl_msg(i,s) (s)
  237. #endif
  238.  
  239. /*
  240. ** yacc user known macros and defines
  241. */
  242. #define YYERROR        goto yyerrlab
  243.  
  244. #ifndef __RUNTIME_YYMAXDEPTH
  245. #define YYACCEPT    return(0)
  246. #define YYABORT        return(1)
  247. #else
  248. #define YYACCEPT    {free_stacks(); return(0);}
  249. #define YYABORT        {free_stacks(); return(1);}
  250. #endif
  251.  
  252. #define YYBACKUP( newtoken, newvalue )\
  253. {\
  254.     if ( yychar >= 0 || ( yyr2[ yytmp ] >> 1 ) != 1 )\
  255.     {\
  256.         yyerror( (nl_msg(30001,"syntax error - cannot backup")) );\
  257.         goto yyerrlab;\
  258.     }\
  259.     yychar = newtoken;\
  260.     yystate = *yyps;\
  261.     yylval = newvalue;\
  262.     goto yynewstate;\
  263. }
  264. #define YYRECOVERING()    (!!yyerrflag)
  265. #ifndef YYDEBUG
  266. #    define YYDEBUG    1    /* make debugging available */
  267. #endif
  268.  
  269. /*
  270. ** user known globals
  271. */
  272. int yydebug;            /* set to 1 to get debugging */
  273.  
  274. /*
  275. ** driver internal defines
  276. */
  277. /* define for YYFLAG now generated by yacc program. */
  278. /*#define YYFLAG        (FLAGVAL)*/
  279.  
  280. /*
  281. ** global variables used by the parser
  282. */
  283. # ifndef __RUNTIME_YYMAXDEPTH
  284. YYSTYPE yyv[ YYMAXDEPTH ];    /* value stack */
  285. int yys[ YYMAXDEPTH ];        /* state stack */
  286. # else
  287. YYSTYPE *yyv;            /* pointer to malloc'ed value stack */
  288. int *yys;            /* pointer to malloc'ed stack stack */
  289. extern char *malloc(), *realloc();
  290. extern void free();
  291. int allocate_stacks(); 
  292. void free_stacks();
  293. # ifndef YYINCREMENT
  294. # define YYINCREMENT (YYMAXDEPTH/2) + 10
  295. # endif
  296. # endif
  297. long  yymaxdepth = YYMAXDEPTH;
  298.  
  299. YYSTYPE *yypv;            /* top of value stack */
  300. int *yyps;            /* top of state stack */
  301.  
  302. int yystate;            /* current state */
  303. int yytmp;            /* extra var (lasts between blocks) */
  304.  
  305. int yynerrs;            /* number of errors */
  306. int yyerrflag;            /* error recovery flag */
  307. int yychar;            /* current input token number */
  308.  
  309.  
  310.  
  311. /*
  312. ** yyparse - return 0 if worked, 1 if syntax error not recovered from
  313. */
  314. int
  315. yyparse()
  316. {
  317.     register YYSTYPE *yypvt;    /* top of value stack for $vars */
  318.  
  319.     /*
  320.     ** Initialize externals - yyparse may be called more than once
  321.     */
  322. # ifdef __RUNTIME_YYMAXDEPTH
  323.     if (allocate_stacks()) YYABORT;
  324. # endif
  325.     yypv = &yyv[-1];
  326.     yyps = &yys[-1];
  327.     yystate = 0;
  328.     yytmp = 0;
  329.     yynerrs = 0;
  330.     yyerrflag = 0;
  331.     yychar = -1;
  332.  
  333.     goto yystack;
  334.     {
  335.         register YYSTYPE *yy_pv;    /* top of value stack */
  336.         register int *yy_ps;        /* top of state stack */
  337.         register int yy_state;        /* current state */
  338.         register int  yy_n;        /* internal state number info */
  339.  
  340.         /*
  341.         ** get globals into registers.
  342.         ** branch to here only if YYBACKUP was called.
  343.         */
  344.     yynewstate:
  345.         yy_pv = yypv;
  346.         yy_ps = yyps;
  347.         yy_state = yystate;
  348.         goto yy_newstate;
  349.  
  350.         /*
  351.         ** get globals into registers.
  352.         ** either we just started, or we just finished a reduction
  353.         */
  354.     yystack:
  355.         yy_pv = yypv;
  356.         yy_ps = yyps;
  357.         yy_state = yystate;
  358.  
  359.         /*
  360.         ** top of for (;;) loop while no reductions done
  361.         */
  362.     yy_stack:
  363.         /*
  364.         ** put a state and value onto the stacks
  365.         */
  366. #if YYDEBUG
  367.         /*
  368.         ** if debugging, look up token value in list of value vs.
  369.         ** name pairs.  0 and negative (-1) are special values.
  370.         ** Note: linear search is used since time is not a real
  371.         ** consideration while debugging.
  372.         */
  373.         if ( yydebug )
  374.         {
  375.             register int yy_i;
  376.  
  377.             printf( "State %d, token ", yy_state );
  378.             if ( yychar == 0 )
  379.                 printf( "end-of-file\n" );
  380.             else if ( yychar < 0 )
  381.                 printf( "-none-\n" );
  382.             else
  383.             {
  384.                 for ( yy_i = 0; yytoks[yy_i].t_val >= 0;
  385.                     yy_i++ )
  386.                 {
  387.                     if ( yytoks[yy_i].t_val == yychar )
  388.                         break;
  389.                 }
  390.                 printf( "%s\n", yytoks[yy_i].t_name );
  391.             }
  392.         }
  393. #endif /* YYDEBUG */
  394.         if ( ++yy_ps >= &yys[ yymaxdepth ] )    /* room on stack? */
  395.         {
  396. # ifndef __RUNTIME_YYMAXDEPTH
  397.             yyerror( (nl_msg(30002,"yacc stack overflow")) );
  398.             YYABORT;
  399. # else
  400.             /* save old stack bases to recalculate pointers */
  401.             YYSTYPE * yyv_old = yyv;
  402.             int * yys_old = yys;
  403.             yymaxdepth += YYINCREMENT;
  404.             yys = (int *) realloc(yys, yymaxdepth * sizeof(int));
  405.             yyv = (YYSTYPE *) realloc(yyv, yymaxdepth * sizeof(YYSTYPE));
  406.             if (yys==0 || yyv==0) {
  407.                 yyerror( (nl_msg(30002,"yacc stack overflow")) );
  408.                 YYABORT;
  409.                 }
  410.             /* Reset pointers into stack */
  411.             yy_ps = (yy_ps - yys_old) + yys;
  412.             yyps = (yyps - yys_old) + yys;
  413.             yy_pv = (yy_pv - yyv_old) + yyv;
  414.             yypv = (yypv - yyv_old) + yyv;
  415. # endif
  416.  
  417.         }
  418.         *yy_ps = yy_state;
  419.         *++yy_pv = yyval;
  420.  
  421.         /*
  422.         ** we have a new state - find out what to do
  423.         */
  424.     yy_newstate:
  425.         if ( ( yy_n = yypact[ yy_state ] ) <= YYFLAG )
  426.             goto yydefault;        /* simple state */
  427. #if YYDEBUG
  428.         /*
  429.         ** if debugging, need to mark whether new token grabbed
  430.         */
  431.         yytmp = yychar < 0;
  432. #endif
  433.         if ( ( yychar < 0 ) && ( ( yychar = yylex() ) < 0 ) )
  434.             yychar = 0;        /* reached EOF */
  435. #if YYDEBUG
  436.         if ( yydebug && yytmp )
  437.         {
  438.             register int yy_i;
  439.  
  440.             printf( "Received token " );
  441.             if ( yychar == 0 )
  442.                 printf( "end-of-file\n" );
  443.             else if ( yychar < 0 )
  444.                 printf( "-none-\n" );
  445.             else
  446.             {
  447.                 for ( yy_i = 0; yytoks[yy_i].t_val >= 0;
  448.                     yy_i++ )
  449.                 {
  450.                     if ( yytoks[yy_i].t_val == yychar )
  451.                         break;
  452.                 }
  453.                 printf( "%s\n", yytoks[yy_i].t_name );
  454.             }
  455.         }
  456. #endif /* YYDEBUG */
  457.         if ( ( ( yy_n += yychar ) < 0 ) || ( yy_n >= YYLAST ) )
  458.             goto yydefault;
  459.         if ( yychk[ yy_n = yyact[ yy_n ] ] == yychar )    /*valid shift*/
  460.         {
  461.             yychar = -1;
  462.             yyval = yylval;
  463.             yy_state = yy_n;
  464.             if ( yyerrflag > 0 )
  465.                 yyerrflag--;
  466.             goto yy_stack;
  467.         }
  468.  
  469.     yydefault:
  470.         if ( ( yy_n = yydef[ yy_state ] ) == -2 )
  471.         {
  472. #if YYDEBUG
  473.             yytmp = yychar < 0;
  474. #endif
  475.             if ( ( yychar < 0 ) && ( ( yychar = yylex() ) < 0 ) )
  476.                 yychar = 0;        /* reached EOF */
  477. #if YYDEBUG
  478.             if ( yydebug && yytmp )
  479.             {
  480.                 register int yy_i;
  481.  
  482.                 printf( "Received token " );
  483.                 if ( yychar == 0 )
  484.                     printf( "end-of-file\n" );
  485.                 else if ( yychar < 0 )
  486.                     printf( "-none-\n" );
  487.                 else
  488.                 {
  489.                     for ( yy_i = 0;
  490.                         yytoks[yy_i].t_val >= 0;
  491.                         yy_i++ )
  492.                     {
  493.                         if ( yytoks[yy_i].t_val
  494.                             == yychar )
  495.                         {
  496.                             break;
  497.                         }
  498.                     }
  499.                     printf( "%s\n", yytoks[yy_i].t_name );
  500.                 }
  501.             }
  502. #endif /* YYDEBUG */
  503.             /*
  504.             ** look through exception table
  505.             */
  506.             {
  507.                 register int *yyxi = yyexca;
  508.  
  509.                 while ( ( *yyxi != -1 ) ||
  510.                     ( yyxi[1] != yy_state ) )
  511.                 {
  512.                     yyxi += 2;
  513.                 }
  514.                 while ( ( *(yyxi += 2) >= 0 ) &&
  515.                     ( *yyxi != yychar ) )
  516.                     ;
  517.                 if ( ( yy_n = yyxi[1] ) < 0 )
  518.                     YYACCEPT;
  519.             }
  520.         }
  521.  
  522.         /*
  523.         ** check for syntax error
  524.         */
  525.         if ( yy_n == 0 )    /* have an error */
  526.         {
  527.             /* no worry about speed here! */
  528.             switch ( yyerrflag )
  529.             {
  530.             case 0:        /* new error */
  531.                 yyerror( (nl_msg(30003,"syntax error")) );
  532.                 yynerrs++;
  533.                 goto skip_init;
  534.             yyerrlab:
  535.                 /*
  536.                 ** get globals into registers.
  537.                 ** we have a user generated syntax type error
  538.                 */
  539.                 yy_pv = yypv;
  540.                 yy_ps = yyps;
  541.                 yy_state = yystate;
  542.                 yynerrs++;
  543.             skip_init:
  544.             case 1:
  545.             case 2:        /* incompletely recovered error */
  546.                     /* try again... */
  547.                 yyerrflag = 3;
  548.                 /*
  549.                 ** find state where "error" is a legal
  550.                 ** shift action
  551.                 */
  552.                 while ( yy_ps >= yys )
  553.                 {
  554.                     yy_n = yypact[ *yy_ps ] + YYERRCODE;
  555.                     if ( yy_n >= 0 && yy_n < YYLAST &&
  556.                         yychk[yyact[yy_n]] == YYERRCODE)                    {
  557.                         /*
  558.                         ** simulate shift of "error"
  559.                         */
  560.                         yy_state = yyact[ yy_n ];
  561.                         goto yy_stack;
  562.                     }
  563.                     /*
  564.                     ** current state has no shift on
  565.                     ** "error", pop stack
  566.                     */
  567. #if YYDEBUG
  568. #    define _POP_ "Error recovery pops state %d, uncovers state %d\n"
  569.                     if ( yydebug )
  570.                         printf( _POP_, *yy_ps,
  571.                             yy_ps[-1] );
  572. #    undef _POP_
  573. #endif
  574.                     yy_ps--;
  575.                     yy_pv--;
  576.                 }
  577.                 /*
  578.                 ** there is no state on stack with "error" as
  579.                 ** a valid shift.  give up.
  580.                 */
  581.                 YYABORT;
  582.             case 3:        /* no shift yet; eat a token */
  583. #if YYDEBUG
  584.                 /*
  585.                 ** if debugging, look up token in list of
  586.                 ** pairs.  0 and negative shouldn't occur,
  587.                 ** but since timing doesn't matter when
  588.                 ** debugging, it doesn't hurt to leave the
  589.                 ** tests here.
  590.                 */
  591.                 if ( yydebug )
  592.                 {
  593.                     register int yy_i;
  594.  
  595.                     printf( "Error recovery discards " );
  596.                     if ( yychar == 0 )
  597.                         printf( "token end-of-file\n" );
  598.                     else if ( yychar < 0 )
  599.                         printf( "token -none-\n" );
  600.                     else
  601.                     {
  602.                         for ( yy_i = 0;
  603.                             yytoks[yy_i].t_val >= 0;
  604.                             yy_i++ )
  605.                         {
  606.                             if ( yytoks[yy_i].t_val
  607.                                 == yychar )
  608.                             {
  609.                                 break;
  610.                             }
  611.                         }
  612.                         printf( "token %s\n",
  613.                             yytoks[yy_i].t_name );
  614.                     }
  615.                 }
  616. #endif /* YYDEBUG */
  617.                 if ( yychar == 0 )    /* reached EOF. quit */
  618.                     YYABORT;
  619.                 yychar = -1;
  620.                 goto yy_newstate;
  621.             }
  622.         }/* end if ( yy_n == 0 ) */
  623.         /*
  624.         ** reduction by production yy_n
  625.         ** put stack tops, etc. so things right after switch
  626.         */
  627. #if YYDEBUG
  628.         /*
  629.         ** if debugging, print the string that is the user's
  630.         ** specification of the reduction which is just about
  631.         ** to be done.
  632.         */
  633.         if ( yydebug )
  634.             printf( "Reduce by (%d) \"%s\"\n",
  635.                 yy_n, yyreds[ yy_n ] );
  636. #endif
  637.         yytmp = yy_n;            /* value to switch over */
  638.         yypvt = yy_pv;            /* $vars top of value stack */
  639.         /*
  640.         ** Look in goto table for next state
  641.         ** Sorry about using yy_state here as temporary
  642.         ** register variable, but why not, if it works...
  643.         ** If yyr2[ yy_n ] doesn't have the low order bit
  644.         ** set, then there is no action to be done for
  645.         ** this reduction.  So, no saving & unsaving of
  646.         ** registers done.  The only difference between the
  647.         ** code just after the if and the body of the if is
  648.         ** the goto yy_stack in the body.  This way the test
  649.         ** can be made before the choice of what to do is needed.
  650.         */
  651.         {
  652.             /* length of production doubled with extra bit */
  653.             register int yy_len = yyr2[ yy_n ];
  654.  
  655.             if ( !( yy_len & 01 ) )
  656.             {
  657.                 yy_len >>= 1;
  658.                 yyval = ( yy_pv -= yy_len )[1];    /* $$ = $1 */
  659.                 yy_state = yypgo[ yy_n = yyr1[ yy_n ] ] +
  660.                     *( yy_ps -= yy_len ) + 1;
  661.                 if ( yy_state >= YYLAST ||
  662.                     yychk[ yy_state =
  663.                     yyact[ yy_state ] ] != -yy_n )
  664.                 {
  665.                     yy_state = yyact[ yypgo[ yy_n ] ];
  666.                 }
  667.                 goto yy_stack;
  668.             }
  669.             yy_len >>= 1;
  670.             yyval = ( yy_pv -= yy_len )[1];    /* $$ = $1 */
  671.             yy_state = yypgo[ yy_n = yyr1[ yy_n ] ] +
  672.                 *( yy_ps -= yy_len ) + 1;
  673.             if ( yy_state >= YYLAST ||
  674.                 yychk[ yy_state = yyact[ yy_state ] ] != -yy_n )
  675.             {
  676.                 yy_state = yyact[ yypgo[ yy_n ] ];
  677.             }
  678.         }
  679.                     /* save until reenter driver code */
  680.         yystate = yy_state;
  681.         yyps = yy_ps;
  682.         yypv = yy_pv;
  683.     }
  684.     /*
  685.     ** code supplied by user is placed in this switch
  686.     */
  687.     switch( yytmp )
  688.     {
  689.         
  690. case 1:
  691. # line 84 "closyacc.y"
  692. {yyret=yypvt[-0].s_expr;YYACCEPT;} break;
  693. case 2:
  694. # line 86 "closyacc.y"
  695. { error(E_SYNTAX,ERR_MERROR|ERR_PVOID|ERR_TNORM,NULL);
  696.                   yyret=VOID;YYACCEPT;
  697.         } break;
  698. case 3:
  699. # line 91 "closyacc.y"
  700. {yyval.s_expr=yypvt[-0].s_expr;} break;
  701. case 4:
  702. # line 92 "closyacc.y"
  703. {yyval.s_expr=yypvt[-0].s_expr;} break;
  704. case 5:
  705. # line 93 "closyacc.y"
  706. {yyval.s_expr=yypvt[-0].s_expr;} break;
  707. case 6:
  708. # line 97 "closyacc.y"
  709. { TYPE(yyval.s_expr=node_make())|=NT_IS_VALUE+NT_INTEGER;
  710.                   INTEGER(yyval.s_expr)=yypvt[-0].integer;
  711.                 } break;
  712. case 7:
  713. # line 101 "closyacc.y"
  714. { TYPE(yyval.s_expr=node_make())|=NT_IS_VALUE+NT_REAL;
  715.                   REAL(yyval.s_expr)=yypvt[-0].real;
  716.                 } break;
  717. case 8:
  718. # line 105 "closyacc.y"
  719. { yyval.s_expr=node_make();STRING(yyval.s_expr)=string_put(yypvt[-0].ident,yyval.s_expr);
  720.                   TYPE(yyval.s_expr)|=NT_IS_VALUE+NT_STRING;
  721.                 } break;
  722. case 9:
  723. # line 109 "closyacc.y"
  724. { yyval.s_expr=node_alloc(yypvt[-0].ident);
  725.                 } break;
  726. case 10:
  727. # line 112 "closyacc.y"
  728. { sprintf(buf1,"Char '%c' ascii %i",(char)yypvt[-2].integer,(int)yypvt[-2].integer);
  729.                   error(E_BADCH,ERR_MERROR|ERR_TNORM|ERR_PSTRING,buf1);
  730.                   yyret=VOID;YYACCEPT;
  731.                 } break;
  732. case 11:
  733. # line 117 "closyacc.y"
  734. {
  735.                   error(E_BADSTRING,ERR_MERROR|ERR_TNORM|ERR_PVOID,NULL);
  736.                   yyret=VOID;YYACCEPT;
  737.                 } break;
  738. case 12:
  739. # line 122 "closyacc.y"
  740. {
  741.                   error(E_INVALIDSQB,ERR_MERROR|ERR_TNORM|ERR_PVOID,NULL);
  742.                   yyret=VOID;YYACCEPT;
  743.                 } break;
  744. case 13:
  745. # line 129 "closyacc.y"
  746. { TYPE(yyval.s_expr=node_make())|=NT_IS_VALUE+NT_ENAME;
  747.                   ENAME(yyval.s_expr)=yypvt[-0].s_expr;
  748.                 } break;
  749. case 14:
  750. # line 133 "closyacc.y"
  751. { TYPE(yyval.s_expr=node_make())|=NT_IS_VALUE+NT_CNAME;
  752.                   ENAME(yyval.s_expr)=yypvt[-0].s_expr;
  753.                 } break;
  754. case 15:
  755. # line 137 "closyacc.y"
  756. { yyval.s_expr=node_make();CONSLEFT(yyval.s_expr)=node_alloc("QUOTE");
  757.                   CONSRIGHT(yyval.s_expr)=node_make();CONSLEFT(CONSRIGHT(yyval.s_expr))=yypvt[-0].s_expr;
  758.                   CONSRIGHT(CONSRIGHT(yyval.s_expr))=NIL;
  759.                   TYPE(yyval.s_expr)|=NT_IS_CONS;TYPE(CONSRIGHT(yyval.s_expr))|=NT_IS_CONS;
  760.                 } break;
  761. case 16:
  762. # line 143 "closyacc.y"
  763. { yyval.s_expr=node_make();CONSLEFT(yyval.s_expr)=node_alloc("COMA");
  764.                   CONSRIGHT(yyval.s_expr)=node_make();CONSLEFT(CONSRIGHT(yyval.s_expr))=yypvt[-0].s_expr;
  765.                   CONSRIGHT(CONSRIGHT(yyval.s_expr))=NIL;
  766.                   TYPE(yyval.s_expr)|=NT_IS_CONS;TYPE(CONSRIGHT(yyval.s_expr))|=NT_IS_CONS;
  767.                 } break;
  768. case 17:
  769. # line 149 "closyacc.y"
  770. { yyval.s_expr=node_make();CONSLEFT(yyval.s_expr)=node_alloc("BACKQUOTE");
  771.           CONSRIGHT(yyval.s_expr)=node_make();CONSLEFT(CONSRIGHT(yyval.s_expr))=yypvt[-0].s_expr;
  772.           CONSRIGHT(CONSRIGHT(yyval.s_expr))=NIL;
  773.           TYPE(yyval.s_expr)|=NT_IS_CONS;TYPE(CONSRIGHT(yyval.s_expr))|=NT_IS_CONS;
  774.         } break;
  775. case 18:
  776. # line 155 "closyacc.y"
  777. { yyval.s_expr=node_make();CONSLEFT(yyval.s_expr)=node_alloc("FUNCTION");
  778.                   CONSRIGHT(yyval.s_expr)=node_make();CONSLEFT(CONSRIGHT(yyval.s_expr))=yypvt[-0].s_expr;
  779.                   CONSRIGHT(CONSRIGHT(yyval.s_expr))=NIL;
  780.                   TYPE(yyval.s_expr)|=NT_IS_CONS;TYPE(CONSRIGHT(yyval.s_expr))|=NT_IS_CONS;
  781.                 } break;
  782. case 19:
  783. # line 163 "closyacc.y"
  784. { TYPE(yyval.s_expr=node_make())|=NT_IS_CONS;
  785.                   CONSLEFT(yyval.s_expr)=yypvt[-1].s_expr;CONSRIGHT(yyval.s_expr)=yypvt[-0].s_expr;
  786.                 } break;
  787. case 20:
  788. # line 166 "closyacc.y"
  789. { yyval.s_expr=NIL;} break;
  790. case 21:
  791. # line 168 "closyacc.y"
  792. { TYPE(yyval.s_expr=node_make())|=NT_IS_CONS;
  793.                   CONSLEFT(yyval.s_expr)=yypvt[-6].s_expr;CONSRIGHT(yyval.s_expr)=yypvt[-2].s_expr;
  794.                 } break;
  795. case 23:
  796. # line 175 "closyacc.y"
  797. { if(parcount)
  798.                      PROMPTP
  799.                   else
  800.                      PROMPT
  801.                 } break;
  802.     }
  803.     goto yystack;        /* reset registers in driver code */
  804. }
  805.  
  806. # ifdef __RUNTIME_YYMAXDEPTH
  807.  
  808. int allocate_stacks() {
  809.     /* allocate the yys and yyv stacks */
  810.     yys = (int *) malloc(yymaxdepth * sizeof(int));
  811.     yyv = (YYSTYPE *) malloc(yymaxdepth * sizeof(YYSTYPE));
  812.  
  813.     if (yys==0 || yyv==0) {
  814.        yyerror( (nl_msg(30004,"unable to allocate space for yacc stacks")) );
  815.        return(1);
  816.        }
  817.     else return(0);
  818.  
  819. }
  820.  
  821.  
  822. void free_stacks() {
  823.     if (yys!=0) free(yys);
  824.     if (yyv!=0) free(yyv);
  825. }
  826.  
  827. # endif  /* defined(__RUNTIME_YYMAXDEPTH) */
  828.  
  829.